package com.jdls.day16.work;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * @author 嘉德罗斯
 * @date 2021/8/7
 */
public class Test6 {
    public static void main(String[] args) {
        // 编写线程池两种实现方式（1. 使用工具类， 2. 自己new）
        ThreadPoolExecutor tp = new ThreadPoolExecutor(1,
                2,
                1,
                TimeUnit.SECONDS,
                new ArrayBlockingQueue<>(5),
                Executors.defaultThreadFactory(),
                new ThreadPoolExecutor.AbortPolicy());
        for (int i = 0; i < 4; i++) {
            tp.submit(()-> System.out.println(Thread.currentThread().getName()+"执行"));
        }
        tp.shutdown();
    }
}
